﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 录入类型管理  添加 修改
//最后修改: 2010-10-11
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;


namespace TRPOP.CMS.Web.Admin
{
    public partial class FormInputType_save : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_ContentModel;
        }
        #endregion


        #region 页面变量
        FormInputTypeManage m_FormInputTypeManage = new FormInputTypeManage();
        protected int m_id = 0;
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strMSG = "名称 、FORM元素名";
            if (!PageAssist.CheckForm(txtName, ref strMSG) ||
                !PageAssist.CheckForm(txtFormItem, ref strMSG)
                )
            {
                Alert(strMSG);
                return;
            }
            int.TryParse(GetRequestViewState("id"), out m_id);
            FormInputTypeInfo oFormInputTypeInfo = m_FormInputTypeManage.GetInfoById(m_id);
            if (oFormInputTypeInfo == null)
                oFormInputTypeInfo = new FormInputTypeInfo();
            oFormInputTypeInfo.AddTime = DateTime.Now;
            oFormInputTypeInfo.AddUserId = base.mUserBaseInfo.UserBaseId;
            oFormInputTypeInfo.Description = txtDescription.TextTrim.RemoveHtml();
            oFormInputTypeInfo.Name = txtName.TextTrim.RemoveHtml();
            oFormInputTypeInfo.FormItem = txtFormItem.TextTrim.RemoveHtml();
            SubmitAlertAndParReset(m_FormInputTypeManage.Save(oFormInputTypeInfo));
        }
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            int.TryParse(InitRequestViewState("id"), out m_id);
            FormInputTypeInfo oFormInputTypeInfo = m_FormInputTypeManage.GetInfoById(m_id);
            if (oFormInputTypeInfo != null)
            {
                txtName.Text = oFormInputTypeInfo.Name;
                txtFormItem.Text = oFormInputTypeInfo.FormItem;
                txtDescription.Text = oFormInputTypeInfo.Description;
            }
        }
        #endregion
    }
}
